﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

namespace Project
{
    public enum MonsterType
    {
        /// <summary>
        /// 杂兵
        /// </summary>
        NormalMon,
        /// <summary>
        /// 远程兵
        /// </summary>
        RemoteMon,
        /// <summary>
        /// 高级杂兵
        /// </summary>
        AdvanMon,
        /// <summary>
        /// 厨师怪物
        /// </summary>
        ChefMon,
        /// <summary>
        /// 建筑怪物
        /// </summary>
        buildMon
    }
    public class MonsterBase : MonoBehaviour
    {
        /// <summary>
        /// 生命值
        /// </summary>
        public int health;

        /// <summary>
        /// 移动速度 
        /// </summary>
        public float moveSpeed;

        /// <summary>
        /// 2D刚体
        /// </summary>
        protected Rigidbody2D monRigi2D;

        /// <summary>
        /// 玩家的Transform组件
        /// </summary>
        protected Transform playerTrans;

        /// <summary>
        /// 攻击力
        /// </summary>
        protected int monsAttack;

        /// <summary>
        /// 怪物类型
        /// </summary>
        protected MonsterType monsterType;
        private void Start()
        {

        }

        /// <summary>
        /// 初始化怪物
        /// </summary>
        /// <param name="health">生命值</param>
        /// <param name="moveSpeed">移动速度</param>
        /// <param name="monsAttack">攻击力</param>
        //protected void InitMonster(monsterType = monsterType.NormalMon, health, moveSpeed, monsAttack) {
        //    playerTrans = GameObject.FindGameObjectWithTag("Player").transform;
        //    monRigi2D = this.gameObject.AddComponent<Rigidbody2D>();

        //    this.health = health;
        //    this.moveSpeed = moveSpeed;
        //    this.monsAttack = monsAttack;
        //    this.monsterType = monsterType;
        //}

        protected void MoveTowardsPlayer()
        {
            if (playerTrans != null)
            {
                Vector3 direction = playerTrans.position - transform.position;
                direction.Normalize();
                monRigi2D.velocity = direction * moveSpeed;
            }
        }
    }
}
